<?php
class Database_Write extends Database_Connection_Connective{
    public function __construct(){
        $config = $this->getConfig();
        $this->_instance = parent::__construct(
            $config->master->host,
            $config->master->user,
            $config->master->pwd,
            $config->master->dbname
        );
    
    }
    public function getMysql(){
        $db = new mysqli("127.0.0.1","root","37212918","no");
        return $db->query("select * from no_document");
    }
    public function getConfig(){
        if(Reg::has('db_config')){ 
            $driver = Reg::get('db_config')->db->driver;
            $db_config = Reg::get('db_config')->{$driver};
        } else {
            $config = new Ini(CONFIG_PATH.'database.ini');
            $driver = $config->driver;
            $db_config = $config->{$driver};
        }
        return $db_config;
    }
    public function getMasterInstance(){
        //if(!(self::_instance instanceof writeconnection)){
            //self::_instance = new writeconnection;
        //}
        //return self::_instance;
        //$this->_instance = $this->getInstance($name = null);
    }
    public function t(){
        $sql = "select * from no_document";
        return $this->query($sql);
    }
    public function __destruct(){
        //$this->close();
    }
}
